#include "StdAfx.h"
#include "ClienteleInfo.h"
#include "json/json.h"


ClienteleInfo::ClienteleInfo(void) : 
	m_id(0), m_hasDialed(false), m_visitID(0), 
	m_clientType(-1), m_visitTm(0)
{
	m_inputDate = _T("");
	m_Type = _T("");
	m_Name = _T("");
	m_Mobi = _T("");
	m_Tele = _T("");
	m_Hous = _T("");
	m_Addr = _T("");
	m_Unit = _T("");
	m_IdNo = _T("");
	m_Noti = _T("");
	m_Dscr = _T("");
	m_visitMemo = _T("");
	m_userID = 0;
}


ClienteleInfo::~ClienteleInfo(void)
{
}

void ClienteleInfo::toJsonValue(Json::Value& jsonObj)
{
	if (m_inputDate.GetLength() > 0)
	{
		jsonObj["inputDate"] = m_inputDate.GetBuffer();
	}
	if (m_Type.GetLength() > 0)
	{
		jsonObj["Type"] = m_Type.GetBuffer();
	}
	if (m_Name.GetLength() > 0)
	{
		jsonObj["Name"] = m_Name.GetBuffer();
	}
	if (m_Mobi.GetLength() > 0)
	{
		jsonObj["Mobi"] = m_Mobi.GetBuffer();
	}
	if (m_Tele.GetLength() > 0)
	{
		jsonObj["Tele"] = m_Tele.GetBuffer();
	}
	if (m_Hous.GetLength() > 0)
	{
		jsonObj["Hous"] = m_Hous.GetBuffer();
	}
	if (m_Addr.GetLength() > 0)
	{
		jsonObj["Addr"] = m_Addr.GetBuffer();
	}
	if (m_Unit.GetLength() > 0)
	{
		jsonObj["Unit"] = m_Unit.GetBuffer();
	}
	if (m_IdNo.GetLength() > 0)
	{
		jsonObj["IdNo"] = m_IdNo.GetBuffer();
	}
	if (m_Noti.GetLength() > 0)
	{
		jsonObj["Noti"] = m_Noti.GetBuffer();
	}
	if (m_Dscr.GetLength() > 0)
	{
		jsonObj["Dscr"] = m_Dscr.GetBuffer();
	}
	
}

void ClienteleInfo::parseFromJson(Json::Value& curJson)
{
	if (!curJson["id"].isNull())
	{
		this->m_id = curJson["id"].asInt();
	}
	if (!curJson["inputDate"].isNull())
	{
		this->m_inputDate = curJson["inputDate"].asCString();
	}
	if (!curJson["Type"].isNull())
	{
		this->m_Type = curJson["Type"].asCString();
	}	
	CUtils::getJsonStringField(curJson, "Name", m_Name);
	if (!curJson["Mobi"].isNull())
	{
		this->m_Mobi = curJson["Mobi"].asCString();
	}
	if (!curJson["Tele"].isNull())
	{
		this->m_Tele = curJson["Tele"].asCString();
	}
	
	CUtils::getJsonStringField(curJson, "Hous", m_Hous);
	CUtils::getJsonStringField(curJson, "Addr", m_Addr);
	CUtils::getJsonStringField(curJson, "Unit", m_Unit);
	CUtils::getJsonStringField(curJson, "Noti", m_Noti);
	CUtils::getJsonStringField(curJson, "Dscr", m_Dscr);
	if (!curJson["IdNo"].isNull())
	{
		this->m_IdNo = curJson["IdNo"].asCString();
	}
	//m_Noti = "mpa013080";
}

